unit GL_BALANCE_TRACE;


interface
uses
  Classes,SysUtils,DB,Uni,UniEngine;

type
  TGLBALANCETRACE=class(TUniEngine)
  private
    FVOUID    : string;
    FSETYEAR  : Extended;
    FRGCODE   : string;
    FVOUTYPEID: Extended;
    FCTRLID   : Extended;
    FCTRLTYPE : string;
    FCTRLSIDE : Extended;             
    FISPRIMARY: Extended;
    FCREATEDATE: string;
    FLATESTOPDATE: string;
    FLASTVER  : string;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property VOUID    : string read FVOUID     write FVOUID;
    property SETYEAR  : Extended read FSETYEAR   write FSETYEAR;
    property RGCODE   : string read FRGCODE    write FRGCODE;
    property VOUTYPEID: Extended read FVOUTYPEID write FVOUTYPEID;
    property CTRLID   : Extended read FCTRLID    write FCTRLID;
    property CTRLTYPE : string read FCTRLTYPE  write FCTRLTYPE;
    property CTRLSIDE : Extended read FCTRLSIDE  write FCTRLSIDE;
    property ISPRIMARY: Extended read FISPRIMARY write FISPRIMARY;
    property CREATEDATE: string read FCREATEDATE write FCREATEDATE;
    property LATESTOPDATE: string read FLATESTOPDATE write FLATESTOPDATE;
    property LASTVER  : string read FLASTVER   write FLASTVER;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AGLBALANCETRACE:TGLBALANCETRACE):TGLBALANCETRACE;overload;        
    class procedure CopyIt(AGLBALANCETRACE:TGLBALANCETRACE;var Result:TGLBALANCETRACE);overload;       
  end;

implementation

{ TGLBALANCETRACE }
procedure TGLBALANCETRACE.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('VOU_ID').Value := VOUID;
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('VOU_TYPE_ID').Value := VOUTYPEID;
        ParamByName('CTRLID').Value := CTRLID;
        ParamByName('CTRL_TYPE').Value := CTRLTYPE;
        ParamByName('CTRL_SIDE').Value := CTRLSIDE;
        ParamByName('IS_PRIMARY').Value := ISPRIMARY;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('LAST_VER').Value := LASTVER; 
      end;
      otEdit:
      begin
        ParamByName('VOU_ID').Value := VOUID;
        ParamByName('SET_YEAR').Value := SETYEAR;
        ParamByName('RG_CODE').Value := RGCODE;
        ParamByName('VOU_TYPE_ID').Value := VOUTYPEID;
        ParamByName('CTRLID').Value := CTRLID;
        ParamByName('CTRL_TYPE').Value := CTRLTYPE;
        ParamByName('CTRL_SIDE').Value := CTRLSIDE;
        ParamByName('IS_PRIMARY').Value := ISPRIMARY;
        ParamByName('CREATE_DATE').Value := CREATEDATE;
        ParamByName('LATEST_OP_DATE').Value := LATESTOPDATE;
        ParamByName('LAST_VER').Value := LASTVER; 
      end;  
      otDelt:
      begin
 
      end;  
    end;
  end;
end;

function TGLBALANCETRACE.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('GL_BALANCE_TRACE',[],AUniConnection);
end;

function TGLBALANCETRACE.GetNextIdex: Integer;
begin

end;

function TGLBALANCETRACE.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TGLBALANCETRACE.GetStrDelete: string;
begin
  Result:='DELETE FROM GL_BALANCE_TRACE WHERE  ';
end;

function TGLBALANCETRACE.GetStrInsert: string;
begin
  Result:='INSERT INTO GL_BALANCE_TRACE'
         +'    ( VOU_ID, SET_YEAR, RG_CODE, VOU_TYPE_ID, CTRLID, CTRL_TYPE'
         +'    , CTRL_SIDE, IS_PRIMARY, CREATE_DATE, LATEST_OP_DATE'
         +'    , LAST_VER)'
         +'    VALUES'
         +'    (:VOU_ID,:SET_YEAR,:RG_CODE,:VOU_TYPE_ID,:CTRLID,:CTRL_TYPE'
         +'    ,:CTRL_SIDE,:IS_PRIMARY,:CREATE_DATE,:LATEST_OP_DATE'
         +'    ,:LAST_VER)';
end;

function TGLBALANCETRACE.GetStrsIndex: string;
begin
  Result:=Format('',[]);
end;

function TGLBALANCETRACE.GetStrUpdate: string;
begin
  raise Exception.Create('NOT SUPPORT THIS METHOD:[TGLBALANCETRACE.GetStrUpdate] AT [GL_BALANCE_TRACE.pas]');
end;

constructor TGLBALANCETRACE.Create;
begin

end;

destructor TGLBALANCETRACE.Destroy;
begin

  inherited;
end;

class function TGLBALANCETRACE.ReadDS(AUniQuery: TUniQuery): TUniEngine;
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  Result:=TGLBALANCETRACE.Create;

  with TGLBALANCETRACE(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='VOU_ID' then
      begin
        VOUID    :=Field.AsString;
      end else
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='VOU_TYPE_ID' then
      begin
        VOUTYPEID:=Field.AsFloat;
      end else
      if FieldName='CTRLID' then
      begin
        CTRLID   :=Field.AsFloat;
      end else
      if FieldName='CTRL_TYPE' then
      begin
        CTRLTYPE :=Field.AsString;
      end else
      if FieldName='CTRL_SIDE' then
      begin
        CTRLSIDE :=Field.AsFloat;
      end else
      if FieldName='IS_PRIMARY' then
      begin
        ISPRIMARY:=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end;
    end
  end;  
end;

class procedure TGLBALANCETRACE.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
var
  I:Integer;
  Field:TField;
  FieldName:string;
begin
  if Result=nil then Exit;

  with TGLBALANCETRACE(Result) do
  begin
    for I:=0 to AUniQuery.Fields.Count-1 do
    begin
      Field:=AUniQuery.Fields.Fields[I];
      //if field.fieldname is not all uppercase,please use uppercase().
      FieldName:=Field.FieldName;
      if FieldName='VOU_ID' then
      begin
        VOUID    :=Field.AsString;
      end else
      if FieldName='SET_YEAR' then
      begin
        SETYEAR  :=Field.AsFloat;
      end else
      if FieldName='RG_CODE' then
      begin
        RGCODE   :=Field.AsString;
      end else
      if FieldName='VOU_TYPE_ID' then
      begin
        VOUTYPEID:=Field.AsFloat;
      end else
      if FieldName='CTRLID' then
      begin
        CTRLID   :=Field.AsFloat;
      end else
      if FieldName='CTRL_TYPE' then
      begin
        CTRLTYPE :=Field.AsString;
      end else
      if FieldName='CTRL_SIDE' then
      begin
        CTRLSIDE :=Field.AsFloat;
      end else
      if FieldName='IS_PRIMARY' then
      begin
        ISPRIMARY:=Field.AsFloat;
      end else
      if FieldName='CREATE_DATE' then
      begin
        CREATEDATE:=Field.AsString;
      end else
      if FieldName='LATEST_OP_DATE' then
      begin
        LATESTOPDATE:=Field.AsString;
      end else
      if FieldName='LAST_VER' then
      begin
        LASTVER  :=Field.AsString;
      end;
    end
  end;  
end;

class function  TGLBALANCETRACE.CopyIt(AGLBALANCETRACE: TGLBALANCETRACE): TGLBALANCETRACE;
begin
  Result:=TGLBALANCETRACE.Create;
  TGLBALANCETRACE.CopyIt(AGLBALANCETRACE,Result)
end;

class procedure TGLBALANCETRACE.CopyIt(AGLBALANCETRACE:TGLBALANCETRACE;var Result:TGLBALANCETRACE);
begin
  if Result=nil then Exit;
  Result.VOUID    :=AGLBALANCETRACE.VOUID;
  Result.SETYEAR  :=AGLBALANCETRACE.SETYEAR;
  Result.RGCODE   :=AGLBALANCETRACE.RGCODE;
  Result.VOUTYPEID:=AGLBALANCETRACE.VOUTYPEID;
  Result.CTRLID   :=AGLBALANCETRACE.CTRLID;
  Result.CTRLTYPE :=AGLBALANCETRACE.CTRLTYPE;
  Result.CTRLSIDE :=AGLBALANCETRACE.CTRLSIDE;
  Result.ISPRIMARY:=AGLBALANCETRACE.ISPRIMARY;
  Result.CREATEDATE:=AGLBALANCETRACE.CREATEDATE;
  Result.LATESTOPDATE:=AGLBALANCETRACE.LATESTOPDATE;
  Result.LASTVER  :=AGLBALANCETRACE.LASTVER;
end;

end.

